package com.zhou.common.operator.log.storage.api;

import com.zhou.common.operator.log.core.model.OperateLogInfo;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.Date;

@Data
public class OperateLogRecord {
    private Long id;
    private String action;
    private String resource;
    private String businessId;
    private String userId;
    private String userName;
    private String orgName;
    private String orgId;
    private String browser;
    private String browserVersion;
    private String os;
    private String clientIp;
    private String serverIp;
    private String remark;
    private Date addTime;
    private String operatingSystem;
    private String operatingInstruction;
    private String operatingType;
    private String operatingModule;
    private String userPhone;
    private String macAddress;

    public OperateLogRecord convertTo(OperateLogInfo info) {
        BeanUtils.copyProperties(info, this);
        BeanUtils.copyProperties(info.getClientInfo(), this);
        BeanUtils.copyProperties(info.getPrincipal(), this);
        BeanUtils.copyProperties(info.getPayloadInfo(), this);
        return this;
    }
}
